package com.satan.fmmall.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName RedissonClient
 * @Description TODO
 * @date 2022/5/1 12:49
 * @Version 1.0
 */
@Configuration
public class RedissonConfig {
    @Value("${spring.redis.cluster.nodes}")
    private String nodes;
    @Bean
    RedissonClient redissonClient() {
        //1、创建配置
        Config config = new Config();
        config.useClusterServers()
                .setScanInterval(2000) // cluster state scan interval in milliseconds
                //192.168.120.130:6379,192.168.120.130:6380,192.168.120.130:6381
                .addNodeAddress(nodes.split(","));
        RedissonClient redissonClient = Redisson.create(config);
        return redissonClient;
    }

}
